home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Source: /mit/kerberos/src/lib/krb/RCS/k_gethostname.c,v $
- * $Author: jtkohl $
- *
- * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
- *
- * For copying and distribution information, please see the file
- * <mit-copyright.h>.
- */
-
- #ifndef lint
- static char rcsid_k_gethostname_c[] =
- "$Header: k_gethostname.c,v 4.1 88/12/01 14:04:42 jtkohl Exp $";
- #endif /* lint */
-
- #include <mit_copy.h>
- #include <string.h>
-
- #ifndef PC
- #ifndef BSD42
- teach me how to k_gethostname for your system here
- #endif
- #endif
-
- /*
- * Return the local host's name in "name", up to "namelen" characters.
- * "name" will be null-terminated if "namelen" is big enough.
- * The return code is 0 on success, -1 on failure. (The calling
- * interface is identical to gethostname(2).)
- *
- * Currently defined for BSD 4.2 and PC. The BSD version just calls
- * gethostname(); the PC code was taken from "kinit.c", and may or may
- * not work.
- */
-
- void k_gethostname(name, namelen)
- char *name;
- {
- #ifdef PC
- char *p="localhost";
- if (rhost(&p)==-1)
- return -1;
- strncpy(name,p,namelen);
- #else
- #ifdef BSD42
- return gethostname(name, namelen);
- #endif
- #endif PC
- }
-